using System;
using System.Collections;
using System.Collections.Generic;
using LL.Data.Mapping;


namespace NanoERP.Model
{
    /// <summary>
    /// 订单信息（主表）
    /// </summary>
    [Serializable]
    public sealed class Orderinfo
    {
        #region Private Members

        // Variabili di stato
        private bool _isChanged;

        // Primary Key(s) 
        private long _id;

        // Properties 
        private int? _billtype;
        private string _orderno;
        private string _customno;
        private DateTime? _orderdate;
        private DateTime? _deliverydate;
        private long? _clientid;
        private long? _busiuserid;
        private int? _storageid;
        private string _summary;
        private string _note;
        private decimal? _summoney;
        private decimal? _deratemoney;
        private int? _deratetype;
        private decimal? _derateagion;
        private decimal? _oughtmoney;
        private int? _invoicetype;
        private string _payaccount;
        private decimal? _paymoney;
        private long? _createuserid;
        private DateTime? _createdate;
        private int? _state;
        private long? _curphasenum;
        private string _curphasename;
        private DateTime? _curphasedate;
        private long? _curphaseuserid;
        private int? _exestate;
        private DateTime? _finishedate;
        private int? _ispatch;
        private string _exfield1;
        private string _exfield2;
        private string _exfield3;
        private decimal? _exfield4;
        private decimal? _recmoneysum;
        private decimal? _paymoneysum;
        private string _note2;
        private string _exfield5;
        private string _exfield6;
        private string _exfield7;
        private string _exfield8;
        private string _exfield9;
        private string _exfield10;
        private string _itemname;
        private long? _maxnum;
        private string _inouttype;

        // One-to-many relations 
        private List<Orderdetail> _listOrderdetail;

        #endregion

        #region Default ( Empty ) Class Constructor

        /// <summary>
        /// default constructor
        /// </summary>
        public Orderinfo()
        {
            _id = 0;
            _billtype = null;
            _orderno = null;
            _customno = null;
            _orderdate = DateTime.Now;
            _deliverydate = DateTime.Now;
            _clientid = null;
            _busiuserid = null;
            _storageid = null;
            _summary = null;
            _note = null;
            _summoney = null;
            _deratemoney = null;
            _deratetype = null;
            _derateagion = 100;
            _oughtmoney = null;
            _invoicetype = null;
            _payaccount = null;
            _paymoney = null;
            _createuserid = null;
            _createdate = DateTime.Now;
            _state = 1;
            _curphasenum = null;
            _curphasename = null;
            _curphasedate = null;
            _curphaseuserid = null;
            _exestate = 1;
            _finishedate = null;
            _ispatch = 0;
            _exfield1 = null;
            _exfield2 = null;
            _exfield3 = null;
            _exfield4 = null;
            _recmoneysum = null;
            _paymoneysum = null;
            _note2 = null;
            _exfield5 = null;
            _exfield6 = null;
            _exfield7 = null;
            _exfield8 = null;
            _exfield9 = null;
            _exfield10 = null;
            _itemname = null;
            _maxnum = null;
            _inouttype = null;
            _listOrderdetail = null;
        }

        #endregion // End of Default ( Empty ) Class Constructor

        #region Full Constructor

        /// <summary>
        /// full constructor
        /// </summary>
        public Orderinfo(long id, int? billtype, string orderno, string customno, DateTime? orderdate, DateTime? deliverydate, long? clientid, long? busiuserid, int? storageid, string summary, string note, decimal? summoney, decimal? deratemoney, int? deratetype, decimal? derateagion, decimal? oughtmoney, int? invoicetype, string payaccount, decimal? paymoney, long? createuserid, DateTime? createdate, int? state, long? curphasenum, string curphasename, DateTime? curphasedate, long? curphaseuserid, int? exestate, DateTime? finishedate, int? ispatch, string exfield1, string exfield2, string exfield3, decimal? exfield4, decimal? recmoneysum, decimal? paymoneysum, string note2, string exfield5, string exfield6, string exfield7, string exfield8, string exfield9, string exfield10, string itemname, long? maxnum, string inouttype)
        {
            _id = id;
            _billtype = billtype;
            _orderno = orderno;
            _customno = customno;
            _orderdate = orderdate;
            _deliverydate = deliverydate;
            _clientid = clientid;
            _busiuserid = busiuserid;
            _storageid = storageid;
            _summary = summary;
            _note = note;
            _summoney = summoney;
            _deratemoney = deratemoney;
            _deratetype = deratetype;
            _derateagion = derateagion;
            _oughtmoney = oughtmoney;
            _invoicetype = invoicetype;
            _payaccount = payaccount;
            _paymoney = paymoney;
            _createuserid = createuserid;
            _createdate = createdate;
            _state = state;
            _curphasenum = curphasenum;
            _curphasename = curphasename;
            _curphasedate = curphasedate;
            _curphaseuserid = curphaseuserid;
            _exestate = exestate;
            _finishedate = finishedate;
            _ispatch = ispatch;
            _exfield1 = exfield1;
            _exfield2 = exfield2;
            _exfield3 = exfield3;
            _exfield4 = exfield4;
            _recmoneysum = recmoneysum;
            _paymoneysum = paymoneysum;
            _note2 = note2;
            _exfield5 = exfield5;
            _exfield6 = exfield6;
            _exfield7 = exfield7;
            _exfield8 = exfield8;
            _exfield9 = exfield9;
            _exfield10 = exfield10;
            _itemname = itemname;
            _maxnum = maxnum;
            _inouttype = inouttype;
            _listOrderdetail = null;
        }

        #endregion // End Full Constructor

        #region Public Properties

        /// <summary>
        /// 主键
        /// </summary>		
        public long Id
        {
            get { return _id; }
            set { _isChanged |= (_id != value); _id = value; }
        }

        /// <summary>
        /// 单据类型ID来自于表BILLTYPEINFO
        /// </summary>		
        public int? Billtype
        {
            get { return _billtype; }
            set { _isChanged |= (_billtype != value); _billtype = value; }
        }

        /// <summary>
        /// 单据类型名称
        /// </summary>
        [IgnoreAttribute()]
        public string BilltypeName { get; set; }

        /// <summary>
        /// 订单编号
        /// </summary>		
        public string Orderno
        {
            get { return _orderno; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Orderno", value, value.ToString());

                _isChanged |= (_orderno != value); _orderno = value;
            }
        }

        /// <summary>
        /// 自定义编号
        /// </summary>		
        public string Customno
        {
            get { return _customno; }
            set
            {
                if (value != null)
                    if (value.Length > 100)
                        throw new ArgumentOutOfRangeException("Invalid value for Customno", value, value.ToString());

                _isChanged |= (_customno != value); _customno = value;
            }
        }

        /// <summary>
        /// 订单日期
        /// </summary>		
        public DateTime? Orderdate
        {
            get { return _orderdate; }
            set { _isChanged |= (_orderdate != value); _orderdate = value; }
        }

        /// <summary>
        /// 到货日期
        /// </summary>		
        public DateTime? Deliverydate
        {
            get { return _deliverydate; }
            set { _isChanged |= (_deliverydate != value); _deliverydate = value; }
        }

        /// <summary>
        /// 供应商编号 表：CLIENTINFO
        /// </summary>		
        public long? Clientid
        {
            get { return _clientid; }
            set { _isChanged |= (_clientid != value); _clientid = value; }
        }

        /// <summary>
        /// 供应商名称
        /// </summary>
        [IgnoreAttribute()]
        public string ClientName { get; set; }

        /// <summary>
        /// 经手人 表：USERINFO
        /// </summary>		
        public long? Busiuserid
        {
            get { return _busiuserid; }
            set { _isChanged |= (_busiuserid != value); _busiuserid = value; }
        }

        /// <summary>
        /// 经手人名称
        /// </summary>
        [IgnoreAttribute()]
        public string BusiuserName { get; set; }

        /// <summary>
        /// 仓库编号 表：STORAGEINFO
        /// </summary>		
        public int? Storageid
        {
            get { return _storageid; }
            set { _isChanged |= (_storageid != value); _storageid = value; }
        }

        /// <summary>
        /// 仓库名称
        /// </summary>
        [IgnoreAttribute()]
        public string StorageName { get; set; }

        /// <summary>
        /// 商品名称+数量+单位
        /// </summary>		
        public string Summary
        {
            get { return _summary; }
            set
            {
                if (value != null)
                    if (value.Length > 4000)
                        throw new ArgumentOutOfRangeException("Invalid value for Summary", value, value.ToString());

                _isChanged |= (_summary != value); _summary = value;
            }
        }

        /// <summary>
        /// 备注
        /// </summary>		
        public string Note
        {
            get { return _note; }
            set
            {
                if (value != null)
                    if (value.Length > 2000)
                        throw new ArgumentOutOfRangeException("Invalid value for Note", value, value.ToString());

                _isChanged |= (_note != value); _note = value;
            }
        }

        /// <summary>
        /// 小计
        /// </summary>		
        public decimal? Summoney
        {
            get { return _summoney; }
            set { _isChanged |= (_summoney != value); _summoney = value; }
        }

        /// <summary>
        /// 整单优惠
        /// </summary>		
        public decimal? Deratemoney
        {
            get { return _deratemoney; }
            set { _isChanged |= (_deratemoney != value); _deratemoney = value; }
        }

        /// <summary>
        /// 优惠类型
        /// </summary>		
        public int? Deratetype
        {
            get { return _deratetype; }
            set { _isChanged |= (_deratetype != value); _deratetype = value; }
        }

        /// <summary>
        /// 整单折扣
        /// </summary>		
        public decimal? Derateagion
        {
            get { return _derateagion; }
            set { _isChanged |= (_derateagion != value); _derateagion = value; }
        }

        /// <summary>
        /// 应付金额
        /// </summary>		
        public decimal? Oughtmoney
        {
            get { return _oughtmoney = _summoney; }
            set { _isChanged |= (_oughtmoney != value); _oughtmoney = value; }
        }

        /// <summary>
        /// 发票类型
        /// </summary>		
        public int? Invoicetype
        {
            get { return _invoicetype; }
            set { _isChanged |= (_invoicetype != value); _invoicetype = value; }
        }

        /// <summary>
        /// 发票类型名称
        /// </summary>
        [IgnoreAttribute()]
        public string InvoicetypeName { get; set; }

        /// <summary>
        /// 付款帐户
        /// </summary>		
        public string Payaccount
        {
            get { return _payaccount; }
            set
            {
                if (value != null)
                    if (value.Length > 200)
                        throw new ArgumentOutOfRangeException("Invalid value for Payaccount", value, value.ToString());

                _isChanged |= (_payaccount != value); _payaccount = value;
            }
        }

        /// <summary>
        /// 预付定金
        /// </summary>		
        public decimal? Paymoney
        {
            get { return _paymoney; }
            set { _isChanged |= (_paymoney != value); _paymoney = value; }
        }

        /// <summary>
        /// 创建人编号 表：USERINFO
        /// </summary>		
        public long? Createuserid
        {
            get { return _createuserid; }
            set { _isChanged |= (_createuserid != value); _createuserid = value; }
        }

        /// <summary>
        /// 创建人名称
        /// </summary>
        [IgnoreAttribute()]
        public string CreateuserName { get; set; }

        /// <summary>
        /// 创建日期
        /// </summary>		
        public DateTime? Createdate
        {
            get { return _createdate; }
            set { _isChanged |= (_createdate != value); _createdate = value; }
        }

        /// <summary>
        /// 状态，默认为1待审核、2为一级审核
        /// </summary>		
        public int? State
        {
            get { return _state; }
            set { _isChanged |= (_state != value); _state = value; }
        }

        /// <summary>
        /// 状态，默认为1待审核、2为一级审核
        /// </summary>
        [IgnoreAttribute()]
        public string StateName { get; set; }

        /// <summary>
        /// 当前审核编号(PHASENUM)  表：FLOWPHASE
        /// </summary>		
        public long? Curphasenum
        {
            get { return _curphasenum; }
            set { _isChanged |= (_curphasenum != value); _curphasenum = value; }
        }

        /// <summary>
        /// 当前审核环节  表：FLOWPHASE
        /// </summary>		
        public string Curphasename
        {
            get { return _curphasename; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Curphasename", value, value.ToString());

                _isChanged |= (_curphasename != value); _curphasename = value;
            }
        }

        /// <summary>
        /// 当前审核日期   
        /// </summary>		
        public DateTime? Curphasedate
        {
            get { return _curphasedate; }
            set { _isChanged |= (_curphasedate != value); _curphasedate = value; }
        }

        /// <summary>
        /// 当前审核人ID
        /// </summary>		
        public long? Curphaseuserid
        {
            get { return _curphaseuserid; }
            set { _isChanged |= (_curphaseuserid != value); _curphaseuserid = value; }
        }

        /// <summary>
        /// 当前审核人名称
        /// </summary>
        [IgnoreAttribute()]
        public string CurphaseuserName { get; set; }

        /// <summary>
        /// 执行状态，默认为1 未完成
        /// </summary>		
        public int? Exestate
        {
            get { return _exestate; }
            set { _isChanged |= (_exestate != value); _exestate = value; }
        }

        /// <summary>
        /// 执行状态名称
        /// </summary>
        [IgnoreAttribute()]
        public string ExestateName { get; set; }

        /// <summary>
        /// 执行日期
        /// </summary>		
        public DateTime? Finishedate
        {
            get { return _finishedate; }
            set { _isChanged |= (_finishedate != value); _finishedate = value; }
        }

        /// <summary>
        /// 是否补单
        /// </summary>		
        public int? Ispatch
        {
            get { return _ispatch; }
            set { _isChanged |= (_ispatch != value); _ispatch = value; }
        }

        /// <summary>
        /// 扩展属性一
        /// </summary>		
        public string Exfield1
        {
            get { return _exfield1; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Exfield1", value, value.ToString());

                _isChanged |= (_exfield1 != value); _exfield1 = value;
            }
        }

        /// <summary>
        /// 扩展属性二
        /// </summary>		
        public string Exfield2
        {
            get { return _exfield2; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Exfield2", value, value.ToString());

                _isChanged |= (_exfield2 != value); _exfield2 = value;
            }
        }

        /// <summary>
        /// 扩展属性三
        /// </summary>		
        public string Exfield3
        {
            get { return _exfield3; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Exfield3", value, value.ToString());

                _isChanged |= (_exfield3 != value); _exfield3 = value;
            }
        }

        /// <summary>
        /// 扩展属性四
        /// </summary>		
        public decimal? Exfield4
        {
            get { return _exfield4; }
            set { _isChanged |= (_exfield4 != value); _exfield4 = value; }
        }

        /// <summary>
        /// 应收帐款
        /// </summary>		
        public decimal? Recmoneysum
        {
            get { return _recmoneysum; }
            set { _isChanged |= (_recmoneysum != value); _recmoneysum = value; }
        }

        /// <summary>
        /// 应付帐款
        /// </summary>		
        public decimal? Paymoneysum
        {
            get { return _paymoneysum; }
            set { _isChanged |= (_paymoneysum != value); _paymoneysum = value; }
        }

        /// <summary>
        /// 附记
        /// </summary>		
        public string Note2
        {
            get { return _note2; }
            set
            {
                if (value != null)
                    if (value.Length > 2000)
                        throw new ArgumentOutOfRangeException("Invalid value for Note2", value, value.ToString());

                _isChanged |= (_note2 != value); _note2 = value;
            }
        }

        /// <summary>
        /// 扩展属性5
        /// </summary>		
        public string Exfield5
        {
            get { return _exfield5; }
            set
            {
                if (value != null)
                    if (value.Length > 100)
                        throw new ArgumentOutOfRangeException("Invalid value for Exfield5", value, value.ToString());

                _isChanged |= (_exfield5 != value); _exfield5 = value;
            }
        }

        /// <summary>
        /// 扩展属性6
        /// </summary>		
        public string Exfield6
        {
            get { return _exfield6; }
            set
            {
                if (value != null)
                    if (value.Length > 100)
                        throw new ArgumentOutOfRangeException("Invalid value for Exfield6", value, value.ToString());

                _isChanged |= (_exfield6 != value); _exfield6 = value;
            }
        }

        /// <summary>
        /// 扩展属性7
        /// </summary>		
        public string Exfield7
        {
            get { return _exfield7; }
            set
            {
                if (value != null)
                    if (value.Length > 100)
                        throw new ArgumentOutOfRangeException("Invalid value for Exfield7", value, value.ToString());

                _isChanged |= (_exfield7 != value); _exfield7 = value;
            }
        }

        /// <summary>
        /// 扩展属性8
        /// </summary>		
        public string Exfield8
        {
            get { return _exfield8; }
            set
            {
                if (value != null)
                    if (value.Length > 100)
                        throw new ArgumentOutOfRangeException("Invalid value for Exfield8", value, value.ToString());

                _isChanged |= (_exfield8 != value); _exfield8 = value;
            }
        }

        /// <summary>
        /// 扩展属性9
        /// </summary>		
        public string Exfield9
        {
            get { return _exfield9; }
            set
            {
                if (value != null)
                    if (value.Length > 100)
                        throw new ArgumentOutOfRangeException("Invalid value for Exfield9", value, value.ToString());

                _isChanged |= (_exfield9 != value); _exfield9 = value;
            }
        }

        /// <summary>
        ///  扩展属性10
        /// </summary>		
        public string Exfield10
        {
            get { return _exfield10; }
            set
            {
                if (value != null)
                    if (value.Length > 100)
                        throw new ArgumentOutOfRangeException("Invalid value for Exfield10", value, value.ToString());

                _isChanged |= (_exfield10 != value); _exfield10 = value;
            }
        }

        /// <summary>
        /// 项目名称
        /// </summary>		
        public string Itemname
        {
            get { return _itemname; }
            set
            {
                if (value != null)
                    if (value.Length > 100)
                        throw new ArgumentOutOfRangeException("Invalid value for Itemname", value, value.ToString());

                _isChanged |= (_itemname != value); _itemname = value;
            }
        }

        /// <summary>
        /// 最大数量
        /// </summary>		
        public long? Maxnum
        {
            get { return _maxnum; }
            set { _isChanged |= (_maxnum != value); _maxnum = value; }
        }

        /// <summary>
        /// 应付类型
        /// </summary>		
        public string Inouttype
        {
            get { return _inouttype; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Inouttype", value, value.ToString());

                _isChanged |= (_inouttype != value); _inouttype = value;
            }
        }

        /// <summary>
        /// 
        /// </summary>		
        [IgnoreAttribute()]
        public List<Orderdetail> ListOrderdetail
        {
            get { return _listOrderdetail; }
            set { _isChanged |= (_listOrderdetail != value); _listOrderdetail = value; }
        }

        #endregion


    }
}